var RoomMap={
	id:'',
	scale:0,
};
RoomMap.addPoint = function(x,y,imgUrl,options){
	var nowW = $("#_m_i",top.document).width();
	var rW = 0;
	var thisM = this;
	var ti = setInterval(function(){
		rW = $("#_r_m_i",top.document).width();
		if(rW != 0){
			window.clearInterval(ti);
			var xD = nowW/rW;
			var xp = x/(thisM.scale/xD) - 10;
			var yp = y/(thisM.scale/xD) + 10;
			var t = (new Date()).getTime() + options.id;
			var imgIcon="<div class='room-point' id='"+t+"' style='width:20px;height:20px;position:absolute;cursor:pointer;z-index:30;left:"+xp+"px;top:"+(0-yp)+"px;'>" +
							"<img src='"+imgUrl+"' width='100%' height='100%'/>" +
						"</div>";
			$("#point-layer",top.document).append(imgIcon);
			$("#"+t,top.document).unbind("click");
			$("#"+t,top.document).click(function(){
				var x = $(this).css("left");
				var y = $(this).css("top");
				RoomMap.infoWindow(x,y,options);
			});
		}
	}, 50);
	
};
RoomMap.clearPoints = function(){
	$(".room-point",top.document).remove();
};
RoomMap.infoWindow = function(x,y,options){
	if(options == undefined || options == "undefined"){
		options = {};
	}
	if(options.width == undefined || options.width == "undefined"){
		options.width = 200;
	}
	if(options.height == undefined || options.height == "undefined"){
		options.height = 150;
	}
	if(options.contents == undefined || options.contents == "undefined"){
		options.contents = "";
	}
	if(options.title == undefined || options.title == "undefined"){
		options.title = "";
	}
	var xp2 = x.split("p")[0]*1;
	var yp2 = y.split("p")[0]*1;
	var xp = xp2 + $(".room-point",top.document).width();
	var yp = yp2 - options.height;
	if(yp < 0){
		yp = yp2 + $(".room-point",top.document).height();;
	}
	if((xp+options.width) > $("#point-layer",top.document).width()){
		xp = xp2 - options.width;
	}
	x = xp+"px";y = yp+"px";
	$(".dia-win",top.document).remove();
	var styleStr = "box-shadow:4px 6px 8px #666;"+
					"-moz-box-shadow:4px 6px 8px #666;"+
					"-webkit-box-shadow:4px 6px 8px #666;" +
					"border:1px solid #e9e9e9;" +
					"overflow:hidden;" +
					"border-radius:2px;" +
					"z-index:32;" +
					"position:absolute;" +
					"background-color:#fff;" +
					"width:"+options.width+"px;" +
					"height:"+options.height+"px;" +
					"left:"+x+";" +
					"top:"+y+";";
	var titleStyStr = "float:left;" +
					"width:100%;" +
					"height:30px;" +
					"line-height:30px;" +
					"padding-left:10px;" +
					"color:#646464;" +
					"font-size:12px;" +
					"border-bottom:1px solid #e9e9e9";
	var closeStyStr = "float:right;" +
					"width:20px;" +
					"height:20px;" +
					"cursor: pointer;" +
					"background-image:url(img/r-close.png);" +
					"background-repeat:no-repeat;" +
					"margin-right:15px;" +
					"margin-top:7px;";
	var bodyStyStr = "float:left;" +
					"width:100%";
	var winHtml = "<div class='dia-win' style='"+styleStr+"'>" +
				  	"<div style='"+titleStyStr+"'>"+options.title+"<div id='close-di-win' style='"+closeStyStr+"'></div></div>" +
				  	"<div style='"+bodyStyStr+"'>"+options.contents+"</div>" +
				  "</div>";
	$("#point-layer",top.document).append(winHtml);
	$("#close-di-win",top.document).unbind("click");
	$("#close-di-win",top.document).click(function(){
		$(".dia-win",top.document).remove();
	}).hover(function(){
		$(this).css("background-image","url(img/r-close1.png)");
	},function(){
		$(this).css("background-image","url(img/r-close.png)");
	});
};
RoomMap.initMap = function(obj,scale,url){
	var _ = RoomMap;
	_.scale = scale;
	obj.empty();
	obj.append("<img style='display:none;' id='_r_m_i'src='"+url+"'>");
	obj.append("<div style='z-index:30;position:absolute;left:0;top:0;width:100%;'><img id='_m_i' width='100%' src='"+url+"'></div>");
	obj.append("<div id='point-layer' style='z-index:31;position:absolute;left:0;top:0;width:"+$("#_m_i",top.document).width()+"px;height:"+$("#_m_i",top.document).height()+"px;'></div>");
};
